<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 1.0 Array.from('伪数组') -- 伪数组转换为真数组
        // 2.0 Array.of();          -- 创建一个新数组
        // 3.0 find                 -- 数组里查找某一项
        // 4.0 findIndex            -- 查找某个值的索引
        // 5.0 includes             -- 判断数组中是否包含某个值
        // 6.0 flat                 -- 数组的扁平化
        // 7.0 at()                 -- 获取数组里的某一项
        // 8.0 fill                 -- 填充数组

        // 3.0 find 数组中查找某一项
        let arr = [1,4,6,3]
        var res = arr.find(item =>item > 5)
        console.log(res);  // 6

        // 4.0 findIndex  查找某个值的索引
        var res = arr.findIndex(item =>item == '3')
        console.log(res); // 3

        // 5.0 includes   判断数组中是否包含某个值
        var res = arr.includes(6)
        console.log(res); // true

        // 6.0 flat        数组的扁平化
        var arrs = [1,2,3,[4,5,6,[7,8,9]]]
        var res = arrs.flat(2)
        console.log(res); // [1, 2, 3, 4, 5, 6, 7, 8, 9]

        // 7.0 at()  获取数组里的某一项
        let arr1 = [1,2,4,5]
        console.log(arr1.at(-1)); // 5 
        console.log(arrs.at(-1).at(-1)); // [7, 8, 9] 

        // 8.0 fill      填充数组
        let arr2 = [2,3,456,6]
        let arr3 = [2,3,456,6]
        console.log(arr2.fill(2)); // [2, 2, 2, 2]
        console.log(arr3.fill(2,0,2)) // [2, 2, 456, 6]
    </script>
</body>
</html>